package org.tp;

import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java_cup.runtime.Symbol;

/** Classe principale**/
public class Main {

	static Env firstEnv = null;
	static Env currentEnv = null;
	static boolean globaleEnv = false;
	static boolean envparametre = false;
	static int cpt = 0;
	static int cpt_operator = 0;
	
	static MyFichier f;
	static Declarations d;
	static Prototypes p;
	static Fonctions func;
	static List<String[]> liste_decla;
	static Set<String> liste_var;
	
	static List<String[]> liste_decla_struct;
	static Map<String, List<String[]>> struct;
	
	static List<String> liste_decla_classe;
	static Map<String, List<String>> classe;
	static boolean typeclasse = true;
	
	static Set<String> varPerInst;
	static Map<Set<String>, String> mapVarPerInst;
	
	static Map<String, String> mapPred;
	
	/** fonction principale du projet**/
	public static void main(String[] args) {
		try {		
			f = new MyFichier();
			d = new Declarations();
			p = new Prototypes();
			func = new Fonctions();
			liste_decla = new ArrayList<String[]>();
			liste_var = new HashSet<String>();
			liste_decla_struct = new ArrayList<String[]>();
			struct = new HashMap<String, List<String[]>>();
			varPerInst = new HashSet<String>();
			mapVarPerInst = new HashMap<Set<String>, String>();
			mapPred = new HashMap<String, String>();
			liste_decla_classe = new ArrayList<String>();
			classe = new HashMap<String, List<String>>();
			
			FileReader  myFile = new FileReader(args[0]);
			TpLexer myLex = new TpLexer(myFile);
			TpParser myP = new TpParser(myLex);
			Symbol result=null;
			
			try {
				result=myP.parse();
				try {
					AbSynt root=(AbSynt)result.value;
					System.out.println(root.toString());
					//root.toDot("detruire");
				}	
				catch (Exception e) {
					System.out.println("result error");
				}
			}
			catch (Exception e) {
				System.out.println("parse error main...");
			}
		}
		catch (Exception e){
			System.out.println("invalid file");	    
		}
	}
}